package bishi.tengxun;


import java.util.Scanner;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/22 21:41
 */
public class fore {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        in.nextLine();
        String str = in.nextLine();
        char[] res = new char[k];
        int[] indexs = new int[k];
        char[] chars = str.toCharArray();
        System.arraycopy(chars, n - k, res, 0, k);
        for (int i = k - 1; i >= 0; i--) {
            indexs[i] = n - k + i;
        }
        for (int i = n - k - 1; i >= 0; i--) {
            char now = chars[i];
            //换位！
            if (res[0] < now) {
                swap(i, 0, indexs, chars, res);
            }
        }
        System.out.println(new String(res));
    }
    /**
10 7
yicfihpfbz
     */


    /**
     * @param i:当前比较的chars[i]
     * @param j:当前的res[j]
     * @param indexs:存的是res中的元素在chars中对应的下标
     * @param chars:原始数组
     * @param res:存的是最优字符
     */
    public static void swap(int i, int j, int[] indexs, char[] chars, char[] res) {
        while (i < indexs[j]) {
            if (res[j] <= chars[i]) {
                indexs[j] = i;
                res[j] = chars[i];
                swap(i + 1, j + 1, indexs, chars, res);
                break;
            }
            i++;
        }
    }
}
